﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Website
{
    public partial class Main : System.Web.UI.Page
    {
        static DataClassesDataContext dc = new DataClassesDataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            initComponents();
        }

        private void initComponents()
        {
            var films = from f in dc.films
                        where f.status == "verwacht"
                        select f;
            foreach (var f in films)
            {
                Image1.ImageUrl = "~/App_Themes/Images/" + f.poster;
            }

            int currentDay = Convert.ToInt32(DateTime.Now.DayOfWeek);

            String day3 = String.Empty;
            String day4 = String.Empty;

            if ((currentDay + 2) < 7)
            {
                day3 = (DateTime.Now.DayOfWeek + 2).ToString();
            }
            else
            {
                day3 = ((DateTime.Now.DayOfWeek + 2) - 7).ToString();
            }
            
            if ((currentDay + 3) < 7)
            {
                day4 = (DateTime.Now.DayOfWeek + 3).ToString();
            }
            else
            {
                day4 = ((DateTime.Now.DayOfWeek + 3) - 7).ToString();
            }

            cmdDay3.Text = translateDayOfWeek(day3);
            cmdDay4.Text = translateDayOfWeek(day4);
        }

        private String translateDayOfWeek(String name)
        {
            String returnvalue = String.Empty;

            switch (name)
            {
                case "Monday":
                    returnvalue = "Maandag";
                    break;
                case "Tuesday":
                    returnvalue = "Dinsdag";
                    break;
                case "Wednesday":
                    returnvalue = "Woensdag";
                    break;
                case "Thursday":
                    returnvalue = "Donderdag";
                    break;
                case "Friday":
                    returnvalue = "Vrijdag";
                    break;
                case "Saturday":
                    returnvalue = "Zaterdag";
                    break;
                case "Sunday":
                    returnvalue = "Zondag";
                    break;
            }

            return returnvalue;
        }
    }
}